<template>
  <el-input :disabled="disabled" :placeholder="placeholder" v-model="sequenceValue" />
</template>

<script>
import { searchSequenceValue } from '../../api/uni';
export default {
  name: 'SerialNumber',
  props: {
    disabled: {
      type: Boolean,
      default: true
    },
    placeholder: {
      type: String,
      default: ''
    },
    modelValue: {
      type: String,
      default: ''
    },
    sequenceCode: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      sequenceValue: ''
    };
  },
  watch: {
    modelValue: {
      handler(newVal) {
        this.sequenceValue = newVal;
      },
      immediate: true
    },
    sequenceValue(newVal, oldVal) {
      this.$emit('update:modelValue', newVal);
    }
  },
  methods: {
    getSequenceValue() {
      if (this.sequenceCode) {
        return searchSequenceValue(this.sequenceCode).then((res) => {
          this.sequenceValue = res.data;
        });
      }
    }
  }
};
</script>
